import greenfoot.*;

/**
 * This class defines a crab. Crabs live on the beach.
 */
public class Crab extends Actor
{
    public void act() 
    {
      move(3);
      turnAtEdge();
      control();
      
      
    }
    public void turnAtEdge(){
        if(isAtEdge()){
          turn(1);
      }
    }
    public void control(){
          if(Greenfoot .isKeyDown("left")){
               turn(-4); 
            }
          if(Greenfoot .isKeyDown("right")){
               turn(4); 
            }
          if(Greenfoot .isKeyDown("up")){
                turn(-4); 
            }
          if(Greenfoot .isKeyDown("down")){
               turn(4); 
            }
    }
}



